
/*
 * ItemView.java
 *
 * Created on Dec 18, 2010, 8:24:52 PM
 */
package ui;

import com.nanosl.lib.log.Loggings;
import ent.Item;
import ent.ItemType;
import ent.LastCode;
import ent.PriceList;
import ent.Stock;
import ent.Supplier;
import java.awt.Component;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.table.DefaultTableModel;
import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
import util.SuperView;

/**
 *
 * @author t
 */
public class ItemView extends SuperView {

    private void KeyAdapter() {
        AutoCompleteDecorator.decorate(supplierComboBox);
        setComboBoxKeyAdapters(supplierComboBox);
    }
    private static ItemView instance = new ItemView();

    public static void display() {
        instance.setVisible(true);
    }

    public static ItemView getInstance() {
        return instance;
    }

    public ItemView() {
        onLoad();
    }

    /**
     * Creates new form ItemView
     */
    public ItemView(java.awt.Frame parent, boolean modal) {
        this();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        masterScrollPane = new javax.swing.JScrollPane();
        masterTable = new javax.swing.JTable();
        jPanel2 = new javax.swing.JPanel();
        brandField = new javax.swing.JTextField();
        descriptionField = new javax.swing.JTextField();
        descriptionLabel = new javax.swing.JLabel();
        supplierComboBox = new javax.swing.JComboBox();
        codeField = new javax.swing.JTextField();
        supplierLabel = new javax.swing.JLabel();
        codeLabel = new javax.swing.JLabel();
        brandLabel = new javax.swing.JLabel();
        updateButton = new javax.swing.JButton();
        deleteButton = new javax.swing.JButton();
        clearButton = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        minimumLimitTextField = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        itemTypeComboBox = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("ITEMS");

        masterTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "#", "Code", "Description", "Quantity", "Price"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        masterTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                masterTableMouseReleased(evt);
            }
        });
        masterTable.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                masterTableKeyReleased(evt);
            }
        });
        masterScrollPane.setViewportView(masterTable);
        masterTable.getColumnModel().getColumn(0).setResizable(false);
        masterTable.getColumnModel().getColumn(0).setPreferredWidth(3);
        masterTable.getColumnModel().getColumn(0).setCellRenderer(rightAlignCell);
        masterTable.getColumnModel().getColumn(1).setResizable(false);
        masterTable.getColumnModel().getColumn(1).setPreferredWidth(5);
        masterTable.getColumnModel().getColumn(2).setResizable(false);
        masterTable.getColumnModel().getColumn(2).setPreferredWidth(200);
        masterTable.getColumnModel().getColumn(3).setResizable(false);
        masterTable.getColumnModel().getColumn(3).setPreferredWidth(6);
        masterTable.getColumnModel().getColumn(3).setCellRenderer(rightAlignCell);
        masterTable.getColumnModel().getColumn(4).setResizable(false);
        masterTable.getColumnModel().getColumn(4).setPreferredWidth(6);
        masterTable.getColumnModel().getColumn(4).setCellRenderer(rightAlignCell);

        brandField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                brandFieldActionPerformed(evt);
            }
        });

        descriptionField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                descriptionFieldActionPerformed(evt);
            }
        });

        descriptionLabel.setText("Description:");

        supplierComboBox.setName("supplierComboBox"); // NOI18N
        supplierComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                supplierComboBoxActionPerformed(evt);
            }
        });
        supplierComboBox.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                supplierComboBoxKeyPressed(evt);
            }
        });

        codeField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                codeFieldActionPerformed(evt);
            }
        });

        supplierLabel.setText("Supplier:");

        codeLabel.setText("Code:");

        brandLabel.setText("Brand:");

        updateButton.setText("Update");
        updateButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                updateButtonActionPerformed(evt);
            }
        });

        deleteButton.setText("Delete");
        deleteButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteButtonActionPerformed(evt);
            }
        });

        clearButton.setText("Clear");
        clearButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clearButtonActionPerformed(evt);
            }
        });

        jLabel1.setText("Minimum Limit:");

        minimumLimitTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                minimumLimitTextFieldActionPerformed(evt);
            }
        });

        jLabel2.setText("Type:");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(codeLabel)
                    .addComponent(descriptionLabel)
                    .addComponent(brandLabel)
                    .addComponent(supplierLabel)
                    .addComponent(jLabel1))
                .addGap(28, 28, 28)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(descriptionField)
                    .addComponent(brandField)
                    .addComponent(supplierComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(minimumLimitTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(updateButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(deleteButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(clearButton))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(codeField, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(itemTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );

        jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {clearButton, deleteButton, updateButton});

        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(codeLabel)
                    .addComponent(codeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2)
                    .addComponent(itemTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(descriptionLabel)
                    .addComponent(descriptionField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(brandLabel)
                    .addComponent(brandField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(supplierLabel)
                    .addComponent(supplierComboBox))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(minimumLimitTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(clearButton)
                    .addComponent(deleteButton)
                    .addComponent(updateButton))
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(masterScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 562, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(masterScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 311, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void clearButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearButtonActionPerformed
        clear();
}//GEN-LAST:event_clearButtonActionPerformed

    private void updateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updateButtonActionPerformed
        update();
}//GEN-LAST:event_updateButtonActionPerformed

    private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteButtonActionPerformed
        delete();
}//GEN-LAST:event_deleteButtonActionPerformed

    private void masterTableKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_masterTableKeyReleased
        fill();
    }//GEN-LAST:event_masterTableKeyReleased

    private void masterTableMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_masterTableMouseReleased
        fill();
    }//GEN-LAST:event_masterTableMouseReleased

    private void codeFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_codeFieldActionPerformed
        String code = codeField.getText().trim();
        if (!code.equals("")) {
            fill(m.find(Item.class, code));
            descriptionField.requestFocus();
        }
    }//GEN-LAST:event_codeFieldActionPerformed

    private void descriptionFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_descriptionFieldActionPerformed
        brandField.requestFocus();
    }//GEN-LAST:event_descriptionFieldActionPerformed

    private void brandFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_brandFieldActionPerformed
        supplierComboBox.requestFocus();
    }//GEN-LAST:event_brandFieldActionPerformed

    private void supplierComboBoxKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_supplierComboBoxKeyPressed
        if (evt.getKeyCode() == 10) {
            minimumLimitTextField.requestFocus();
        }
    }//GEN-LAST:event_supplierComboBoxKeyPressed

    private void supplierComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_supplierComboBoxActionPerformed
    }//GEN-LAST:event_supplierComboBoxActionPerformed

    private void minimumLimitTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_minimumLimitTextFieldActionPerformed
        updateButton.requestFocus();
    }//GEN-LAST:event_minimumLimitTextFieldActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField brandField;
    private javax.swing.JLabel brandLabel;
    private javax.swing.JButton clearButton;
    private javax.swing.JTextField codeField;
    private javax.swing.JLabel codeLabel;
    private javax.swing.JButton deleteButton;
    private javax.swing.JTextField descriptionField;
    private javax.swing.JLabel descriptionLabel;
    private javax.swing.JComboBox itemTypeComboBox;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane masterScrollPane;
    private javax.swing.JTable masterTable;
    private javax.swing.JTextField minimumLimitTextField;
    private javax.swing.JComboBox supplierComboBox;
    private javax.swing.JLabel supplierLabel;
    private javax.swing.JButton updateButton;
    // End of variables declaration//GEN-END:variables
    DefaultTableModel tableModel;

    private void fill() {
        clearFields();
        int row = masterTable.getSelectedRow();
        if (row > -1) {
            Item item = m.find(Item.class, masterTable.getValueAt(row, 1));
            fill(item);
        }
    }

    private void update() {
        String code = codeField.getText().trim();
        String description = descriptionField.getText().trim();
        if (code.equals("")) {
            codeField.requestFocus();
            return;
        }
        if (description.equals("")) {
            descriptionField.requestFocus();
            return;
        }
        String brand = brandField.getText().trim();

        try {
            String minLimText = minimumLimitTextField.getText().trim();
            minLimText = minLimText.isEmpty() ? "0.0" : minLimText;
            double minimumLimit = Double.parseDouble(minLimText);
            Supplier supplier = (Supplier) supplierComboBox.getSelectedItem();
            Item item = m.find(Item.class, code);
            List<Serializable> serializables = new ArrayList<Serializable>();
            if (item == null) {
                item = new Item(code);
                LastCode lastCode = m.find(LastCode.class, "Item");
                lastCode = lastCode == null ? new LastCode("Item") : lastCode;
                lastCode.setCode(code);
                serializables.add(lastCode);
            }
            item.setDescription(description);
            item.setBrand(brand);
            item.setSupplier(supplier);
            ItemType itemType = (ItemType) itemTypeComboBox.getSelectedItem();
            item.setItemTypeType(itemType);
            Stock stock = item.getStock();
            if (stock == null) {
                stock = new Stock(code);
                stock.setBundles(0.0);
                stock.setItem(item);
                stock.setQuantity(0.0);
                stock.setMinLimit(minimumLimit);
                item.setStock(stock);
                serializables.add(stock);
            }
            supplier.getItemCollection().add(item);
            PriceList priceList = m.find(PriceList.class, code);
            priceList = priceList == null ? new PriceList(code) : priceList;
            priceList.setCostPack(0.0);
            priceList.setItem(item);
            priceList.setSellingPack(0.0);
            priceList.setCostPack(0.0);
            item.setPriceList(priceList);
            serializables.add(supplier);
            serializables.add(item);
            serializables.add(priceList);

            if (m.update(serializables)) {
                clear();
                codeField.requestFocus();
                return;
            }
            showError("Unable to update " + code);
        } catch (NumberFormatException e) {
            showError("Check values again");
        } catch (Exception e) {
            Loggings.logError(getName(), e);
        }
    }

    private void delete() {
        String code = codeField.getText().trim();
        if (code.equals("")) {
            codeField.requestFocus();
            return;
        }
        if (m.delete(Item.class, code)) {
            clear();
            setStatusMessage("Item Deleted");
            return;
        }
        showError("Unable to delete " + code);
    }

    private void clear() {
        fillTable();
        fillSuppliers();
        fillItemTypes();
        clearFields();
        codeField.requestFocus();
    }

    private void clearFields() {
        codeField.setText("");
        descriptionField.setText("");
        brandField.setText("");
        minimumLimitTextField.setText("");
        if (supplierComboBox.getItemCount() > 0) {
            supplierComboBox.setSelectedIndex(0);
        }
    }

    private void fillTable() {
        tableModel.setRowCount(0);
        int i = 0;
        List<Serializable> serializables = new ArrayList<Serializable>();
        List<Item> items = m.find(Item.class);
        Collections.sort(items);
        for (Iterator<Item> it = items.iterator(); it.hasNext();) {
            Item item = it.next();
            Stock stock = item.getStock();
            if (stock == null) {
                stock = new Stock(item.getCode());
                stock.setBundles(0.0);
                stock.setItem(item);
                stock.setQuantity(0.0);
                item.setStock(stock);
                serializables.add(stock);
            }
            PriceList priceList = item.getPriceList();

            if (priceList == null) {
                priceList = new PriceList(item.getCode());
                priceList.setCostPack(0.0);
                priceList.setCostUnit(0.0);
                priceList.setSellingPack(0.0);
                priceList.setSellingUnit(0.0);
                priceList.setItem(item);
                item.setPriceList(priceList);
                serializables.add(priceList);
            }
            m.update(serializables);
            double paymentAmount = Double.valueOf(priceList.getSellingPack() != null ? priceList.getSellingPack() : 0);
            Object[] row = {++i, item.getCode(), item.getDescription(), stock.getQuantity(), nf2d.format(paymentAmount)};
            tableModel.addRow(row);
        }
    }

    protected void onLoad() {
        initComponents();
        KeyAdapter();
        tableModel = (DefaultTableModel) masterTable.getModel();
        clear();
    }

    private void fillSuppliers() {
        supplierComboBox.setModel(new DefaultComboBoxModel(m.find(Supplier.class).toArray()));
    }

    private void fillItemTypes() {
        List<ItemType> itemTypes = m.find(ItemType.class);
        if (itemTypes.isEmpty()) {
            m.update(new ItemType("ITEM"));
            m.update(new ItemType("METERIAL"));
        }
        itemTypes = m.find(ItemType.class);
        itemTypeComboBox.setModel(new DefaultComboBoxModel(itemTypes.toArray()));
    }
    KeyAdapter supplierComboBoxKeyAdapter = new java.awt.event.KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent evt) {
            supplierComboBoxKeyPressed(evt);
        }
    };

    private void setComboBoxKeyAdapters(JComboBox supp) {
        String compName = supp.getName();
        Component component[] = supp.getComponents();
        for (int i = 0; i < component.length; i++) {
            if (compName.equals("supplierComboBox")) {
                component[i].addKeyListener(supplierComboBoxKeyAdapter);
            }
        }
    }

    private void fill(Item item) {
        if (item == null) {
            return;
        }
        codeField.setText(item.getCode());
        descriptionField.setText(item.getDescription());
        brandField.setText(item.getBrand());
        supplierComboBox.setSelectedItem(item.getSupplier());
        itemTypeComboBox.setSelectedItem(item.getItemTypeType());
        Stock stock = item.getStock();
        minimumLimitTextField.setText(stock != null ? stock.getMinLimit() != null ? stock.getMinLimit() + "" : "" : "0");
    }

    @Override
    public void setVisible(boolean b) {
        super.setVisible(b);
        fillSuppliers();
    }
}
